package artid.com.arttogoa.adapter;

import java.util.ArrayList;
import java.util.List;
import artid.com.arttogoa.R;
import artid.com.arttogoa.parser.ArtDynamicComment;
import artid.com.arttogoa.util.CircleImageView;
import com.nostra13.universalimageloader.core.ImageLoader;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 
*    
* 项目名称：ArtworkArtA   
* 类名称   ：ArtDynamicDetailAdapter   
* 类描述   ：动态详情评论适配器   
* 创建人   ：耿卫斌   
* 创建时间：2016-8-11 下午12:23:30   
*
 */
public class ArtDynamicDetailAdapter extends BaseAdapter {
	private Context mContext;
	LayoutInflater mInflater;
	ViewHolder holder;
	private ImageLoader mImageLoader;
	public List<ArtDynamicComment> listdata;

	public ArtDynamicDetailAdapter(Context mContext) {
		this.mContext = mContext;
		mInflater = LayoutInflater.from(mContext);
		listdata = new ArrayList<ArtDynamicComment>();
	}

	public void setdata(List<ArtDynamicComment> listdata) {
		this.listdata = listdata;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return listdata.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		if (convertView == null) {
			vh = new ViewHolder();
			convertView = mInflater.inflate(R.layout.item_main_message1, null);
			vh.name = (TextView) convertView.findViewById(R.id.comment_name);
			vh.time = (TextView) convertView.findViewById(R.id.comment_date);
			vh.detail = (TextView) convertView
					.findViewById(R.id.comment_content);
			vh.imgurl = (CircleImageView) convertView.findViewById(R.id.comment_img);
			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}

		ArtDynamicComment item = listdata.get(position);
		vh.name.setText(item.getNickname());
		vh.time.setText(item.getCreate_time());
		vh.detail.setText(item.getContent());
		// if (position % 3 == 0) {
		// convertView = mInflater.inflate(R.layout.item_main_message1, null);
		// } else if (position % 3 == 1) {
		// convertView = mInflater.inflate(R.layout.item_main_message2, null);
		// } else if (position % 3 == 2) {
		// convertView = mInflater.inflate(R.layout.item_main_message3, null);
		// }
		ImageLoader.getInstance().displayImage(item.getImgurl(), vh.imgurl);
		return convertView;
	}

	class ViewHolder {
		TextView name, time, detail;
		CircleImageView imgurl;
	}
}
